package com.jixiang.user.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jixiang.model.common.dtos.ResponseResult;
import com.jixiang.model.user.dtos.AdminUserDtos;
import com.jixiang.model.user.entity.UsUser;
import com.jixiang.user.service.UsUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (UsUser)表控制层
 *
 * @author makejava
 * @since 2023-10-12 13:57:50
 */
@RestController
@RequestMapping("adminUser")
public class AdminUserController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private UsUserService usUserService;

    /**
     * 登录功能
     *
     */
    @ApiOperation("管理端登录")
    @PostMapping("/adminUserLogin")
    public ResponseResult loginAdmin(@RequestBody AdminUserDtos adminUserDtos){
        return usUserService.loginAdmin(adminUserDtos);
    }

    /**
     * 登录功能
     *
     */
    @ApiOperation("获取管理者数据列表")
    @GetMapping("/getAdminList")
    public ResponseResult getAdminList(@RequestParam(value = "pageSize",required = false,defaultValue = "10")int pageSize,
                                       @RequestParam(value = "pageNum",required = false,defaultValue = "1")int pageNum,
                                       @RequestParam(value = "name",required = false,defaultValue = "")String name,
                                       @RequestParam(value = "phone",required = false,defaultValue = "")String phone){
        return usUserService.getAdminList(pageNum,pageSize,name,phone);
    }

    /**
     * 修改用户状态
     *
     */
    @ApiOperation("修改用户状态")
    @PostMapping("/updateUserState")
    public ResponseResult updateUserState(@RequestParam(value = "id",required = true) String id){
            return usUserService.updateUserState(id);
    }

    /**
     * 修改用户状态
     *
     */
    @ApiOperation("修改用户状态")
    @GetMapping("/getAdminById")
    public ResponseResult getAdminById(@RequestParam(value = "id",required = true) String id){
        return usUserService.getAdminById(id);
    }


    /**
     * 修改用户
     *
     */
    @ApiOperation("修改用户")
    @PostMapping ("/updateAdmin")
    public ResponseResult updateAdmin(@RequestBody(required = true) UsUser usUser){
        return usUserService.updateAdmin(usUser);
    }

    /**
     * 删除用户
     *
     */
    @ApiOperation("删除用户")
    @DeleteMapping ("/deleteAdminById")
    public ResponseResult deleteAdminById(@RequestParam(value = "id",required = true) String id){
        return usUserService.deleteAdminById(id);
    }

    /**
     * 添加用户
     *
     */
    @ApiOperation("添加管理用户用户")
    @PostMapping ("/addAdmin")
    public ResponseResult addAdmin(@RequestBody(required = true) UsUser usUser){
        return usUserService.addAdmin(usUser);
    }

}

